﻿Imports ADOEntity
Imports System.Data
Partial Class Administrator_BranchList
    Inherits Web.UI.BasePage
    Private Const strMenuCode As String = "M65"
    Dim BranchEntity As userEntities
    Dim dsBranch As New DataSet
    Dim clsQuery As clsDatabase
    Dim clsDataTable As New clsLINQToDataTable
    Dim intBeforeItemIndex As Integer
    Dim clsMasterDropDown As clsMasterDropDown
    Dim strMsg As String = ""
    Dim clsSessionMenuRight As clsSessionMenuRight

#Region " Even Page "
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        lblBranchCode.Text = Resources.resBranch.branchCode & " : "
        lblBranchName.Text = Resources.resBranch.branchName & " : "
        lblDepartment.Text = Resources.resBranch.department & " : "
        lblZone.Text = Resources.resBranch.Zone & " : "
        lblSOLId.Text = Resources.resBranch.SOL_ID & " : "
        lblCbsSolId.Text = Resources.resBranch.CBS_SOL_ID & " : "


        btnSearch.Text = Resources.resButton.btnSearch
        btnAdd.Text = Resources.resButton.btnAdd
        btnModify.Text = Resources.resButton.btnModify
        btnDelete.Text = Resources.resButton.btnDelete
        btnClear.Text = Resources.resButton.btnClear
        btnPrint.Text = Resources.resButton.btnPrint

        lblMsg.Text = Resources.resMessageAlert.alertEmptyGrid
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            chkIsLogin()
            clsMasterDropDown = New clsMasterDropDown
            BranchEntity = New UserEntities
            clsSessionMenuRight = Session("ClsMenuRight")
            If (Not IsPostBack) Then
                loadDataToDropDown()
                setUserRightButton()

                CreateControlMP()
                setButton(1)
            Else
                dsBranch = Session("dsTblMaster")
                gvBranch.DataSource = dsBranch.Tables("sBranch")
                gvBranch.DataBind()
                setGrid()
            End If
        Catch ex As Exception

        End Try

    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        clsMasterDropDown = Nothing
        BranchEntity = Nothing
        Session("dsTblMaster") = dsBranch
    End Sub

#End Region

#Region "SetForm"

    Sub CreateControlMP()

        Dim lblForm As Label = CType(Master.FindControl("lblForm"), Label)
        lblForm.Text = "ส่วนงาน/สาขา"
    End Sub

#End Region

#Region " Even Button "

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        setButton(1)
        IsDataBind()
        clearGvIndex()
        SaveLogSearch()
    End Sub

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        'Response.Redirect("BranchEdit.aspx?Status=Add")

        Try
            If chkBeforeSave() Then
                BranchEntity = New userEntities
                Dim sBranch As New SBRANCH

                SBRANCH.BRANCHCODE = txtBranchCode.Text
                SBRANCH.BRANCHCODEUSE = txtBranchCode.Text.Substring(0, 3)
                SBRANCH.BRANCHNAME = txtBranchName.Text
                SBRANCH.DEPTCODE = ddlDepartment.SelectedValue
                SBRANCH.ZONECODE = ddlZone.SelectedValue
                SBRANCH.ALLCODERIGHT = ddlDepartment.SelectedValue & "/" & txtBranchCode.Text.Trim & "/" & ddlZone.SelectedValue
                sBranch.SOL_ID = txtSOLId.Text
                sBranch.CBS_SOL_ID = txtCbsSolId.Text
                BranchEntity.AddToSBRANCH(sBranch)
                BranchEntity.SaveChanges()

                SaveLogNew()

                IsDataBind()
                reset()

                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resMsgKYC.msgSave + "')", True)

            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + strMsg + "')", True)

            End If
        Catch ex As System.Data.UpdateException
            Dim codeError() As String = ex.InnerException.Message.Split(":")
            If codeError(0) = "ORA-00001" Then
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถเพิ่มได้ เนื่องจากรหัสนี้มีการนำมาใช้ในระบบแล้ว')", True)
            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)
            End If

        Catch ex As Exception
            WriteError(ex, "btnAdd_Click", "BranchList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('บันทึกผิดพลาด')", True)

        End Try
    End Sub

    Protected Sub btnModify_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModify.Click
        Try
            If chkBeforeSave() Then
                BranchEntity = New UserEntities
                Dim sBranch As New SBRANCH

                Dim qry = (From Branch In BranchEntity.SBRANCH Where Branch.BRANCHCODE = txtBranchCode.Text).ToList
                qry(0).BRANCHNAME = txtBranchName.Text
                qry(0).DEPTCODE = ddlDepartment.SelectedValue
                qry(0).ZONECODE = ddlZone.SelectedValue
                qry(0).ALLCODERIGHT = ddlDepartment.SelectedValue & "/" & txtBranchCode.Text.Trim & "/" & ddlZone.SelectedValue
                qry(0).SOL_ID = txtSOLId.Text
                qry(0).CBS_SOL_ID = txtCbsSolId.Text
                BranchEntity.SaveChanges()

                SaveLogEdit()

                IsDataBind()
                reset()

                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resMsgKYC.msgSave + "')", True)

            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + strMsg + "')", True)

            End If
        Catch ex As System.Data.UpdateException
            Dim codeError() As String = ex.InnerException.Message.Split(":")
            If codeError(0) = "ORA-00001" Then
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถเพิ่มได้ เนื่องจากรหัสนี้มีการนำมาใช้ในระบบแล้ว')", True)
            Else
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)
            End If

        Catch ex As Exception
            WriteError(ex, "btnModify_Click", "BranchList")
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('บันทึกผิดพลาด')", True)

        End Try

    End Sub

    Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click

        If Not (gvBranch.SelectedIndex = -1) Then
            Dim branch As String = gvBranch.Rows(gvBranch.SelectedIndex).Cells(3).Text
            Try
                BranchEntity = New userEntities
                Dim qry = (From s_Branch In BranchEntity.SBRANCH Where s_Branch.BRANCHCODE = branch).ToList
                BranchEntity.DeleteObject(qry(0))
                BranchEntity.SaveChanges()

                SaveLogDelete(branch)

                IsDataBind()
                reset()

            Catch ex As System.Data.UpdateException
                Dim codeError() As String = ex.InnerException.Message.Split(":")
                If codeError(0) = "ORA-02292" Then
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('ไม่สามารถลบได้ เนื่องจากมีการนำมาใช้ในระบบแล้ว')", True)
                Else
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + ex.InnerException.Message + "')", True)
                End If

            Catch ex As Exception
                WriteError(ex, "btnDelete_Click", "BranchList")
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resError.errorMessage + "')", True)

            End Try

        Else

            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" + Resources.resValidate.nonSelectGridDelete + "')", True)

        End If

    End Sub
    Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
        clear()
    End Sub

    Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        Dim param As String = "{ 'rptType' : '5'," _
                              & "'deptCode' : '" & ddlDepartment.SelectedValue & "/" & ddlDepartment.SelectedItem.Text & "'," _
                               & "'zoneCode' : '" & ddlZone.SelectedValue & "/" & ddlZone.SelectedItem.Text & "'," _
                                & "'BranchCode' : '" & txtBranchCode.Text.Trim & "'," _
                              & "'BranchName' : '" & txtBranchName.Text.Trim & "'}"

        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType, "key", "OpenWindowWithPost('../Form/frmPrintRptMaster.aspx','width=730,height=345,left=100,top=100,resizable=yes,scrollbars=yes','Report', " + param + ");", True)

        SaveLogPrint()
    End Sub


#End Region


#Region "Even GridView"

    Protected Sub gvBranch_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvBranch.SelectedIndexChanged
        If (gvBranch.SelectedIndex = intBeforeItemIndex) Then
            clearGvIndex()
            reset()

            btnModify.Text = "แก้ไข"
        Else
            btnModify.Text = "บันทึก"

            setButton(2)

            txtBranchCode.Text = gvBranch.Rows(gvBranch.SelectedIndex).Cells(3).Text
            txtBranchName.Text = gvBranch.Rows(gvBranch.SelectedIndex).Cells(5).Text
            ddlDepartment.SelectedValue = gvBranch.Rows(gvBranch.SelectedIndex).Cells(4).Text
            ddlZone.SelectedValue = gvBranch.Rows(gvBranch.SelectedIndex).Cells(6).Text
            txtSOLId.Text = gvBranch.Rows(gvBranch.SelectedIndex).Cells(7).Text.Replace("&nbsp;", "")
            txtCbsSolId.Text = gvBranch.Rows(gvBranch.SelectedIndex).Cells(8).Text.Replace("&nbsp;", "")

            btnDelete.Attributes.Add("onclick", "return confirm('" + String.Format(Resources.resValidate.confirmDelete, _
                       IIf(gvBranch.SelectedIndex = -1, "", gvBranch.Rows(gvBranch.SelectedIndex).Cells(5).Text)) + "');")
        End If
    End Sub

    Protected Sub gvBranch_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles gvBranch.SelectedIndexChanging
        intBeforeItemIndex = gvBranch.SelectedIndex
    End Sub

    Protected Sub gvBranch_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvBranch.PageIndexChanging
        gvBranch.PageIndex = e.NewPageIndex
        clearGvIndex()
        DataBind()
        setGrid()
    End Sub

    Protected Sub gvBranch_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles gvBranch.Sorting
        Dim dt = TryCast(dsBranch.Tables("sBranch"), DataTable)

        If dt IsNot Nothing Then

            'Sort the data.
            dt.DefaultView.Sort = e.SortExpression & " " & GetSortDirection(e.SortExpression)
            gvBranch.DataSource = dsBranch.Tables("sBranch")
            gvBranch.DataBind()
            clearGvIndex()
            setGrid()
        End If
    End Sub

#End Region

#Region " Function"
    'Private Sub chkIsLogin()
    '    If Session("ClsMenuRight") Is Nothing Then
    '        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "message", _
    '                                                         "alert('กรุณา Login เข้าสู่ระบบก่อน');location.href = '../KYC/index.aspx';", True)
    '    End If
    'End Sub


    Private Sub setUserRightButton()
        Dim col As New Collection

        col.Add(btnSearch, statusbtn.Query.ToString)
        col.Add(btnAdd, statusbtn.Add.ToString)
        col.Add(btnModify, statusbtn.Modify.ToString)
        col.Add(btnDelete, statusbtn.delete.ToString)
        col.Add(btnPrint, statusbtn.print.ToString)
        setBtnToUserRight(col, strMenuCode, clsSessionMenuRight.getDsMenuRight)

    End Sub

    Private Sub loadDataToDropDown(Optional ByVal strDeptCode As String = "", Optional ByVal strZoneCode As String = "")
        Try
            clsMasterDropDown.setDeptToDdlSearch(ddlDepartment, _
                                                  strDeptCode:=clsSessionMenuRight.getDeptCode, _
                                                  strRoleCode:=clsSessionMenuRight.getRoleGroup)

            clsMasterDropDown.setZoneToDdl(ddlZone, selectData:=strZoneCode, strRoleCode:=clsSessionMenuRight.getRoleGroup, _
                                           strZoneCode:=clsSessionMenuRight.getZoneCode, strDeptCode:=ddlDepartment.SelectedValue)

        Catch ex As Exception
            WriteError(ex, "loadDataToDropDown", "BranchList")
        End Try


    End Sub

    Private Sub clearGvIndex()
        gvBranch.SelectedIndex = -1
        '  btnDelete.Attributes.Clear()
    End Sub

    Private Sub IsDataBind()
        Try
            If dsBranch.Tables.Contains("sBranch") Then
                dsBranch.Tables.Clear()
            End If
            Dim qryBranch = From Branch In BranchEntity.SBRANCH Join dept In BranchEntity.SDEPARTMENT On Branch.DEPTCODE Equals dept.DEPTCODE Join zone In BranchEntity.SZONE On Branch.ZONECODE Equals zone.ZONECODE
                            Order By Branch.DEPTCODE, Branch.BRANCHCODE Ascending
                                      Select Branch.BRANCHCODE, Branch.DEPTCODE, Branch.BRANCHNAME, dept.DEPTNAME, Branch.ZONECODE, zone.ZONENAME, Branch.SOL_ID, Branch.CBS_SOL_ID

            If Not (txtBranchCode.Text = "") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.BRANCHCODE.Contains(txtBranchCode.Text))
            End If

            If Not (txtBranchName.Text = "") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.BRANCHNAME.Contains(txtBranchName.Text))
            End If
            If Not (ddlDepartment.SelectedValue = "0") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.DEPTCODE = ddlDepartment.SelectedValue)
            End If
            If Not (ddlZone.SelectedValue = "ZZZ") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.ZONECODE = ddlZone.SelectedValue)
            End If

            If Not (txtSOLId.Text = "") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.SOL_ID.Contains(txtSOLId.Text))
            End If
            If Not (txtCbsSolId.Text = "") Then
                qryBranch = qryBranch.Where(Function(Bran) Bran.CBS_SOL_ID.Contains(txtCbsSolId.Text))
            End If

            dsBranch.Tables.Add(clsDataTable.LINQToDataTable(qryBranch, "sBranch").Copy)

            If (qryBranch.Count = 0) Then
                lblMsg.Visible = True
                lblTotal.Text = ""
            Else
                lblMsg.Visible = False
                lblTotal.Text = "จำนวนรายการทั้งหมด " + qryBranch.Count.ToString + " รายการ "
            End If


            gvBranch.DataSource = dsBranch.Tables("sBranch")
            gvBranch.DataBind()
            setGrid()

            clsDataTable = Nothing
        Catch ex As Exception
            WriteError(ex, "IsDataBind", "BranchList")
        End Try
       

    End Sub

    Private Sub setGrid()
        If Not gvBranch.Rows.Count = 0 Then
            gvBranch.HeaderRow.Cells(4).Visible = False
            gvBranch.HeaderRow.Cells(6).Visible = False
            For i As Integer = 0 To gvBranch.Rows.Count - 1
                gvBranch.Rows(i).Cells(4).Visible = False
                gvBranch.Rows(i).Cells(6).Visible = False
            Next
        End If
    End Sub

    Private Function GetSortDirection(ByVal column As String) As String

        ' By default, set the sort direction to ascending.
        Dim sortDirection = "DESC"

        ' Retrieve the last column that was sorted.
        Dim sortExpression = TryCast(ViewState("SortExpression"), String)

        If sortExpression IsNot Nothing Then
            ' Check if the same column is being sorted.
            ' Otherwise, the default value can be returned.
            If sortExpression = column Then
                Dim lastDirection = TryCast(ViewState("SortDirection"), String)
                If lastDirection IsNot Nothing _
                  AndAlso lastDirection = "DESC" Then

                    sortDirection = "ASC"

                End If
            End If
        End If

        ' Save new values in ViewState.
        ViewState("SortDirection") = sortDirection
        ViewState("SortExpression") = column
        Return sortDirection
    End Function

    Private Sub setButton(ByVal button As Integer)

        If button = 1 Then 'unselect
            lblMsg.Visible = False

            btnModify.Enabled = False
            btnDelete.Enabled = False

            btnSearch.Enabled = True
            btnAdd.Enabled = True

            txtBranchCode.Enabled = True

        ElseIf button = 2 Then 'select

            btnSearch.Enabled = False
            btnAdd.Enabled = False

            btnModify.Enabled = True
            btnDelete.Enabled = True

            txtBranchCode.Enabled = False

        End If

    End Sub

    Private Sub clear()
        If dsBranch.Tables.Contains("sBranch") Then
            dsBranch.Tables("sBranch").Clear()
            gvBranch.DataSource = dsBranch.Tables("sBranch")
            gvBranch.DataBind()
        End If

        clearGvIndex()
        setButton(1)
        lblMsg.Visible = False
        txtBranchCode.Text = ""
        txtBranchName.Text = ""
        ddlDepartment.SelectedIndex = -1
        ddlZone.SelectedIndex = -1
        txtSOLId.Text = ""
        txtCbsSolId.Text = ""
        lblTotal.Text = ""
        btnModify.Text = "แก้ไข"
    End Sub

    Private Sub reset()
        'gvUserRight.DataSource = dsUserRight.Tables("sBranch")
        'gvUserRight.DataBind()
        clearGvIndex()
        setButton(1)
        lblMsg.Visible = False
        txtBranchCode.Text = ""
        txtBranchName.Text = ""
        ddlDepartment.SelectedIndex = -1
        ddlZone.SelectedIndex = -1
        txtSOLId.Text = ""
        txtCbsSolId.Text = ""
    End Sub

    Private Function chkBeforeSave() As Boolean
        Dim result As Boolean = True

        If (txtBranchCode.Text = "") Then
            result = False
            strMsg = strMsg & "กรุณาระบุรหัสสาขา/ส่วนงาน" & "\n"
        End If

        If (txtBranchName.Text = "") Then
            result = False
            strMsg = strMsg & "กรุณาระบุชื่อสาขา/ส่วนงาน" & "\n"
        End If

        If (ddlDepartment.SelectedValue = "0") Then
            result = False
            strMsg = strMsg & "กรุณาระบุฝ่าย" & "\n"
        End If

        If (ddlZone.SelectedValue = "0") Then
            result = False
            strMsg = strMsg & "กรุณาระบุเขต" & "\n"

        End If

        Return result

    End Function

    Private Sub SaveLogSearch()
        Try

            Dim desc As String = ""

            If Not (ddlDepartment.SelectedValue = "0") Then
                desc += " ฝ่าย - " + ddlDepartment.SelectedItem.Text
            End If

            If Not (ddlZone.SelectedValue = "0") Then
                desc += " เขต - " + ddlZone.SelectedItem.Text
            End If

            If Not (txtBranchCode.Text = "") Then
                desc += " รหัสส่วนงาน/สาขา - " + txtBranchCode.Text
            End If

            If Not (txtBranchName.Text = "") Then
                desc += " ชื่อส่วนงาน/สาขา - " + txtBranchName.Text
            End If


            If Not desc = "" Then
                desc = "ค้นหาข้อมูลส่วนงาน/สาขา จาก " + desc
            Else
                desc = "ค้นหาทั้งหมด"
            End If

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction("", clsSessionMenuRight.getUserName, 1, desc, "M65")
            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub SaveLogPrint()
        Try

            Dim desc As String = "พิมพ์ข้อมูลส่วนงาน/สาขา"

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction("", clsSessionMenuRight.getUserName, 2, desc, "M65")
            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub SaveLogNew()
        Try

            Dim desc As String = "บันทึก ข้อมูลส่วนงาน/สาขา (รหัสส่วนงาน/สาขา " + txtBranchCode.Text + ")"

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction(txtBranchCode.Text, clsSessionMenuRight.getUserName, 3, desc, "M65")
            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub SaveLogEdit()
        Try

            Dim desc As String = "บันทึก แก้ไข ข้อมูลส่วนงาน/สาขา (รหัสส่วนงาน/สาขา " + txtBranchCode.Text + ")"

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction(txtBranchCode.Text, clsSessionMenuRight.getUserName, 4, desc, "M65")
            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub SaveLogDelete(ByVal value As String)
        Try

            Dim desc As String = "ลบข้อมูลส่วนงาน/สาขา (รหัสส่วนงาน/สาขา " + value + ")"

            Dim clsLogTransaction As New clsLogTransaction
            clsLogTransaction.saveLogTransaction(value, clsSessionMenuRight.getUserName, 5, desc, "M65")
            clsLogTransaction = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

#End Region


    Protected Sub ddlDepartment_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDepartment.SelectedIndexChanged
        Try
            clsMasterDropDown = New clsMasterDropDown
            If Not (ddlDepartment.SelectedValue = "0") Then
                clsMasterDropDown.setZoneToDdl(ddlData:=ddlZone, strDeptCode:=ddlDepartment.SelectedValue, strRoleCode:=clsSessionMenuRight.getRoleGroup, strZoneCode:=clsSessionMenuRight.getZoneCode)
            Else
                clsMasterDropDown.setZoneToDdl(ddlData:=ddlZone, strDeptCode:=ddlDepartment.SelectedValue, strRoleCode:=clsSessionMenuRight.getRoleGroup, strZoneCode:=clsSessionMenuRight.getZoneCode)
                ddlZone.SelectedValue = "ZZZ"
            End If

            clsMasterDropDown = Nothing
        Catch ex As Exception
            WriteError(ex, "ddlDepartment_SelectedIndexChanged", "BranchList")
        End Try

    End Sub
End Class
